package org.jeecg.modules.system.entity;


import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.common.system.vo.LoginUser;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;

/**
 * @Description: 用户常用表
 * @Author: jeecg-boot
 * @Date: 2024-07-15
 * @Version: V1.0
 */
@Data
@TableName("common_used_app")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "common_used_app对象", description = "用户常用表")
public class CommonUsedApp implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private java.lang.String id;
    /**
     * 用户id
     */
    @Excel(name = "用户id", width = 15)
    @ApiModelProperty(value = "用户id")
    private java.lang.String userId;
    /**
     * 应用id
     */
    @Excel(name = "应用id", width = 15)
    @ApiModelProperty(value = "应用id")
    @NotBlank
    private java.lang.String appId;
    /**
     * 应用ids
     */
    @Excel(name = "应用ids", width = 15)
    @ApiModelProperty(value = "应用ids")
    @TableField(exist = false)
    private java.util.List appIdList;
    /**
     * 应用图标
     */
    @Excel(name = "应用图标", width = 15)
    @ApiModelProperty(value = "应用图标")
    @TableField(exist = false)
    private String applicationIco;
    /**
     * 调用地址
     */
    @Excel(name = "调用地址", width = 100)
    @ApiModelProperty(value = "调用地址")
    @TableField(exist = false)
    private String requestadd;
    /**
     * 应用id
     */
    @Excel(name = "应用名称", width = 35)
    @ApiModelProperty(value = "应用名称")
    @NotBlank
    private java.lang.String appName;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private java.lang.String createBy;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    private java.util.Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private java.lang.String updateBy;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    private java.util.Date updateTime;

    public static CommonUsedApp buildCommonUsedApp(JSONObject jsonElement, LoginUser user) {
        CommonUsedApp commonUsedApp = new CommonUsedApp();
        JSONObject jsonObject = jsonElement;
        String appId = jsonObject.get("appId").toString();
        String appName = jsonObject.get("appName").toString();
        commonUsedApp.setAppId(appId);
        commonUsedApp.setAppName(appName);
        commonUsedApp.setUserId(user.getId());
        commonUsedApp.setCreateTime(new Date());
        commonUsedApp.setCreateBy(user.getLoginName());
        return commonUsedApp;
    }
}
